<?php
class Somi_Form_Jobi extends Zend_Form 
{
	public function init()
	{
		
		$this->setName('Jobi');
		$this->setAction($this->getView()->url())->setMethod('post');
		$this->addAttribs(array('onSubmit'=>'return validate(this)'));
		
		require_once APPLICATION_HTDOCS.'/library/Somi/Validate/ErrorMessageDe.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
		
	
		$this->clearDecorators();


		$formDecorators=array(
		'formElements',
		array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
		'Form',
		);
		
		$elementDecorators=array(
		'ViewHelper',
		'Errors',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
		array('Label',array('class'=>'left')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
		);
		
		$buttonDecorators=array(
		'ViewHelper',
		array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'buttonrow')),
		array(array('row'=>'HtmlTag'),array('tag'=>'div'))
		);
		

		$filterToLower = new Zend_Filter_StringToLower();
        $filterToLower->setEncoding('UTF-8');
		
		# Vorname
		$vorname=new Zend_Form_Element_Text('vorname');
		$vorname->setLabel('Vorname');
		
		# Nachname
		$nachname=new Zend_Form_Element_Text('nachname');
		$nachname->setLabel('Nachname *')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim');
		$nachname->addValidator('notEmpty');
		
		#Email
        $email=new Zend_Form_Element_Text('email');
        $email->setLabel('Email *')
        ->setRequired(true);
        #->setRequired(true)
        $email->setDescription('Email');
        $email->addFilter('StripTags');
        $email->addFilter('StringTrim');
        $email->addFilter($filterToLower);
        $email->addValidator('EmailAddress');
        $email->addValidator('notEmpty');
        $email->addPrefixPath('Somi_Validate', APPLICATION_HTDOCS.'/library/Somi/Validate/', 'validate');
        $email->addValidator('ExistJobi',true);
		$email->setAttrib('class','email');
		
		
		#stadt
		$stadt = new Zend_Form_Element_Text('stadt');
		$stadt->setLabel('Stadt');
		
		
		#phone1
		$phone1 = new Zend_Form_Element_Text('phone1');
		$phone1->setLabel('Phone1');
		
		#phone2
		$phone2 = new Zend_Form_Element_Text('phone2');
		$phone2->setLabel('Phone2');
		
		#Tätigkeit
		$taetigkeit = new Zend_Form_Element_Text('taetigkeit');
		$taetigkeit->setLabel('Tätigkeit');
		
		#Qualifikation
		$qualifikation = new Zend_Form_Element_Textarea('qualifikation');
		$qualifikation->setLabel('Qualifikation');
		
		#Status
		$jobi = new Somi_Models_Jobi();
        $statusen = $jobi->getStatus();	
		$status = new Zend_Form_Element_Select('status');
		$status->setLabel('Status');
		foreach($statusen as $v)
        {
        	$status->addMultiOption($v,$v);
        }
		
		
		#Kommentar
		$kommentar = new Zend_Form_Element_Textarea('kommentar');
		$kommentar->setLabel('kommentar');
		
		#AGB
		$agb = new Zend_Form_Element_Checkbox('agb');
		$agb->setLabel('AGB *');
		$agb->setRequired(true);
		$agb->setUncheckedValue('')->addErrorMessage('Bitte bestätigen Sie unsere AGB');
		$agb->setAttrib('style','width:12px;padding-left:0px;');
		
		#Submit
		$submit=new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Senden');
		$submit->setAttrib('class','form-button');
		


		# Send Elements
		$this->addElements(array($status,$vorname,$nachname,$email,$agb,$phone1,$phone2,$stadt,$taetigkeit,$qualifikation,$kommentar,$submit));
			
		#$form->addDisplayGroup(array('vorname','password','submit'),'login');
		
		$this->setDecorators($formDecorators);
		$this->setElementDecorators($elementDecorators);
		$this->getElement('submit')->setDecorators($buttonDecorators);
	}
}


?>